<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>RSA密匙</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		function submitBtn(){
			//表单提交
			$.ajax({
				url:"${ctx}/rsa/update",
				data : {id:'${rsaKey.id}'},
				cache : false,
				dataType : 'JSON',
				type:'post',
				beforeSend:function(){
	             		//防止表单重复提交
					$.jBox.tip("数据提交中...", 'loading');
	             },
				success:function(data){
					$.jBox.closeTip();
					if(data.code == "0000"){
						//成功替换值
						$("#appKey").val(data.body.appKey);
						$("#dlPrivateKey").val(data.body.dlPrivateKey);
						$("#pfPublicKey").val(data.body.pfPublicKey);
						$.jBox.success('RSA重新生成成功。</br><span style="color:red;">请务必保存好系统生成公密匙.</span>', '提示');
					}else{
						$.jBox.error(data.msg, '提示');
					}
				},
				error:function(xhr,status,e){
	                 //服务器响应失败时的处理函数
	                 $.jBox.closeTip();
					$.jBox.error("服务端错误", '提示');
	             }
			});
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
	<li class="active">
		<shiro:hasPermission name="news:news:save">
			<a href="${ctx}/rsa/info">RSA密匙设置</a>
		</shiro:hasPermission>
	</li>
</ul><br/>
	<form id="inputForm"  class="form-horizontal">
		<input id="id" name="id" value="${rsaKey.id}" type="hidden">
		<div class="control-group">
			<label class="control-label">app_key：</label>
			<div class="controls">
				<input id="appKey" style="border: 1px solid #ccc;padding: 4px 6px;width: 300px;" readonly="readonly" htmlEscape="false"  maxlength="20" class="input-medium"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">开发者RSA密匙：</label>
			<div class="controls">
				<textarea id="dlPrivateKey"  name="privateKey" readonly="readonly" htmlEscape="false" rows="4" class="input-xxlarge"></textarea>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">平台RSA公匙：</label>
			<div class="controls">
				<textarea id="pfPublicKey"  name="privateKey" readonly="readonly" htmlEscape="false" rows="4" class="input-xxlarge"></textarea>
			</div>
		</div>
		<span class="controls"><font color="red">1:请务必保存好app_key、开发者RSA密钥、平台RSA公匙，用于平台接口加密解密和签名验证</font> </span></br>
		<span class="controls"><font color="red">2:开发者RSA密钥和平台RSA公匙本平台不会进行保存</font> </span></br>
		<span class="controls"><font color="red">3:开发者RSA密钥、平台RSA公匙若丢失请重新生成并保存</font> </span>
		<div class="form-actions">
			<shiro:hasPermission name="rsa:rsa:update">
			<input onclick="submitBtn()" class="btn btn-primary" type="button" value="重新生成"/>&nbsp;
			</shiro:hasPermission>
		</div>
	</form>
</body>
</html>